package com.jike.noobmoney.adapter;


import android.app.Activity;
import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.jike.noobmoney.R;
import com.jike.noobmoney.contants.ConstantValue;
import com.jike.noobmoney.entity.TaskDetailEntity;

import java.util.ArrayList;

import me.iwf.photopicker.PhotoPreview;

/**
 * 列表任务 详情
 **/
public class TaskDetailAdapter extends BaseRecyclerAdapter<TaskDetailEntity.TaskstepBean> {


    private Context context;

    public TaskDetailAdapter(Context context) {
        super(R.layout.item_task_detail);
        this.context = context;
    }

    @Override
    protected void onBindViewHolder(SmartViewHolder holder, TaskDetailEntity.TaskstepBean item, int position) {
        holder.text(R.id.tv_step_title, item.getText());
        ImageView ivStepImage = (ImageView) holder.findViewById(R.id.iv_step_image);
        Glide.with(context).load(ConstantValue.IMG_BASEURL_MARK + item.getPicture()).into(ivStepImage);

        ivStepImage.setOnClickListener(v -> {
            String url = ConstantValue.IMG_BASEURL_MARK + item.getPicture();
            ArrayList<String> photoPaths = new ArrayList<>();
            photoPaths.add(url);
            PhotoPreview.builder()
                    .setPhotos(photoPaths)
                    .setCurrentItem(position)
                    .setShowDeleteButton(true)
                    .start((Activity) context);
        });
    }
}
